//数据返回类型的相同参数
export interface ResponseData {
  code: number
  ok: boolean
  message: string
}
//以下是品牌管理相关类型
export interface recordsDataType {
  id?: number
  tmName: string
  logoUrl: string
}
//品牌管理相关类型
export interface TrademarkResponseData extends ResponseData {
  data: {
    records: recordsDataType[]
    total: number
    ' size': number
    current: number
    ' searchCount': boolean
    pages: number
  }
}

//以下是属性管理相关类型
export interface categoryObj {
  id: number | string
  name: string
  category1Id?: number
  category2Id?: number
  createTime?: string
  updateTime?: string
}

export interface categoryResponseData extends ResponseData {
  data: categoryObj[]
}

export interface AttrValue {
  id?: number
  valueName: string
  attrId?: number
  flag?: boolean
}

export type AttrValueList = AttrValue[]

export interface Attr {
  id?: number
  attrName: string
  categoryId: number | string
  categoryLevel: number
  attrValueList: AttrValueList
}

export type AttrList = Attr[]

export interface AttrResponseData extends ResponseData {
  data: AttrList
}

//以下是SPU管理相关类型
//spu数据类型
export interface spuData {
  id?: number
  spuName: string
  description: string
  category3Id: string | number
  tmId: number | string
  spuSaleAttrList: null | saleAttr[]
  spuImageList: null | SpuImg[]
}
//spu数据列表类型
export type spuRecords = spuData[]
//spu返回数据类型
export interface spuResponseData extends ResponseData {
  data: {
    records: spuRecords
    total: number
    size: number
    current: number
    searchCount: boolean
    pages: number
  }
}

//品牌数据类型
export interface Trademark {
  id: number
  tmName: string
  logoUrl: string
}
//品牌列表数据类型
export interface AllTrademarkList extends ResponseData {
  data: Trademark[]
}

//spu某一商品的照片数据类型
export interface SpuImg {
  id?: number
  createTime?: string
  updateTime?: string
  spuId?: number
  imgName?: string
  imgUrl?: string
  name?: string
  url: string //url和name是为了适应element组件设置的
}
//spu某一商品的全部照片列表数据类型
export interface SpuImgList extends ResponseData {
  data: SpuImg[]
}

//spu中某一商品的销售属性值数据类型
export interface spuSaleAttrValue {
  id?: number
  createTime?: string
  updateTime?: string
  spuId?: number
  baseSaleAttrId: number | string
  saleAttrValueName: string
  saleAttrName?: string
  isChecked?: null
}

//spu中某一商品的销售属性值的数组列表数据类型
export type spuSaleAttrValueList = spuSaleAttrValue[]

//销售属性对象数据类型
export interface saleAttr {
  id?: number
  createTime?: string
  updateTime?: string
  spuId?: number
  baseSaleAttrId: number
  saleAttrName: string
  spuSaleAttrValueList: spuSaleAttrValueList
  flag?: boolean
  addedAttrValue?: string
}

//销售属性接口返回的数据类型
export interface saleAttrResponseData extends ResponseData {
  data: saleAttr[]
}

//用于筛选剩下可选的SPU销售属性数据类型
export interface existedSaleAttr {
  id: number
  name: string
}

export interface existedSaleAttrResponse extends ResponseData {
  data: existedSaleAttr[]
}

//sku收集的销售属性数据类型  分别是属性名ID和属性值Id
export interface saleArr {
  id?: number
  saleAttrId: number | string //属性ID
  saleAttrValueId: number | string //属性值的ID
}

export interface skuAttr {
  id?: number
  attrId: number | string //平台属性的ID
  valueId: number | string //属性值的ID
}
//收集SKU数据的表单数据类型
export interface SkuData {
  category3Id: string | number //三级分类的ID
  spuId: string | number //已有的SPU的ID
  tmId: string | number //SPU品牌的ID
  skuName: string //sku名字
  price: string | number //sku价格
  weight: string | number //sku重量
  skuDesc: string //sku的描述
  skuAttrValueList?: skuAttr[]
  skuSaleAttrValueList?: saleArr[]
  skuDefaultImg: string //sku图片地址
  isSale?: number //控制商品的上架与下架
  id?: number
}

//获取SKU数据接口的ts类型
export interface SkuInfoData extends ResponseData {
  data: SkuData[]
}

//获取SKU接口返回的数据ts类型
export interface SkuResponseData extends ResponseData {
  data: {
    records: SkuData[]
    total: number
    size: number
    current: number
    orders: []
    optimizeCountSql: boolean
    hitCount: boolean
    countId: null
    maxLimit: null
    searchCount: boolean
    pages: number
  }
}
